﻿@using SCMS.Resource
@model SCMS.UI.Models.POLastStepModel
@{AjaxOptions ajaxOpts = new AjaxOptions
      {
          UpdateTargetId = "PODiv",
          LoadingElementId = "loading",
          HttpMethod = "Post",
          Url = Url.Action("SubmitPurchaseOrder"),
          OnBegin = "return validateConsigneeEmails();"//,
          //OnSuccess = "if (document.getElementById('table') != null) {initSorter();sorter.size(50);}"
      };}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>New PO:: @Model.POEntiy.RefNumber</h3></div>
    @using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
    {
        @Html.ValidationSummary(true)
        <br />
        <table width="98%" align="center" style="margin-left: auto; margin-right: auto;">
            <tr>
                <th colspan="4">
                    @Resources.PurchaseOrder_LoadOtherPODetails_DocumentationRequired
                </th>
            </tr>
            <tr>
                <td width="25%">
                    @Html.EditorFor(p => p.ProformaRequired) @Resources.PurchaseOrder_String_ProformaInvoice
                </td>
                <td width="25%">
                    @Html.EditorFor(p => p.CommercialInvoiceRequired) @Resources.PurchaseOrder_String_OriginalInvoice
                </td>
                <td width="25%">
                    @Html.EditorFor(p => p.WayBillRequired) @Resources.PurchaseOrder_String_WaybillAirbill
                </td>
                <td width="25%">
                    &nbsp;@Html.EditorFor(p => p.PackingListRequired) @Resources.PurchaseOrder_String_PackingList
                </td>
            </tr>
            <tr>
                <td width="25%">
                    @Html.EditorFor(p => p.DeliveryNoteRequired) @Resources.PurchaseOrder_String_DeliveryNote
                </td>
                <td width="25%">
                    @Html.EditorFor(p => p.ManualsRequired) @Resources.PurchaseOrder_LoadOtherPODetails_Manuals
                </td>
                <td width="25%">
                    @Html.EditorFor(p => p.CertificatesReqired) @Resources.PurchaseOrder_LoadOtherPODetails_Certificates
                </td>
                <td width="25%">
                    <table>
                        <tr>
                            <td>@Html.CheckBoxFor(p => p.OtherRequired, new { @id = "otherCheck" })</td>
                            <td>@Html.TextBoxFor(p => p.POEntiy.OtherSpecify, new { id = "otherTb", onblur = "checkUncheck(this, 'otherCheck')" })</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <th>
                    @Resources.Global_String_ManageShippingTerms
                </th>
                <th>
                    @Resources.PurchaseOrder_LoadOtherPODetails_ConsigneeAddress
                </th>
                <th>
                    @Resources.Global_String_EmailAddress 1
                </th>
                <th>
                    @Resources.Global_String_EmailAddress 2
                </th>
            </tr>
            <tr>
                <td>
                    @Html.TextBoxFor(p => p.POEntiy.ShippingMarks)
                </td>
                <td>
                    @Html.TextBoxFor(p => p.POEntiy.ConsigneeAddress)
                </td>
                <td id="csEmail1">
                    @Html.TextBoxFor(p => p.ConsigneeEmail1, new { id = "consigneeEmail1", onblur = "javascript:validateConsigneeEmails()" })
                </td>
                <td id="csEmail2">
                    @Html.TextBoxFor(p => p.ConsigneeEmail2, new { id = "consigneeEmail2", onblur = "javascript:validateConsigneeEmails()" })
                </td>
            </tr>
            <tr>
                <th>
                    @Resources.PurchaseOrder_LoadOtherPODetails_PreFinancing
                </th>
                <th></th>
                <th></th>
                <th></th>
            </tr>
            <tr>
                <td>
                    <table>
                        <tr>
                            <td>@Html.CheckBoxFor(p => p.PrefinancingGuaranteeRequired, new { @id = "pfgCheck" })</td>
                            <td>
                                @Html.TextBoxFor(p => p.POEntiy.PFGPercentage, new { @class = "numericTb", id = "pfgPercentage", onblur = "checkUncheck(this, 'pfgCheck')" })
                                @Html.ValidationMessageFor(p => p.POEntiy.PFGPercentage)
                            </td>
                        </tr>
                    </table>
                </td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </table>
        <table width="98%" align="center">
            <tr>
                <td width="50%">
                    @if (Model.POEntiy.TenderAnalysi == null)
                    {
                        @Ajax.ActionLink("<<" + Resources.Global_String_Back, "LoadSingleQItems", new { id = Model.POEntiy.Id }, new AjaxOptions
                        {
                            UpdateTargetId = "PODiv",
                            LoadingElementId = "loading",
                            Url = Url.Action("LoadSingleQItems/" + Model.POEntiy.Id)
                        })
                    }
                    else
                    { 
                        @Ajax.ActionLink("<<" + Resources.Global_String_Back, "LoadSingleQItems", new { id = Model.POEntiy.Id }, new AjaxOptions
                        {
                            UpdateTargetId = "PODiv",
                            LoadingElementId = "loading",
                            Url = Url.Action("EditPO/" + Model.POEntiy.Id),
                            OnSuccess = "clearPOItemNumbers"
                        })
                    }                    
                </td>
                <td align="right" width="50%">
                    @Html.HiddenFor(p => p.POEntiy.Id)
                    @*<input type="submit" class="btn green" value="@Resources.Global_String_SubmitForReview" />*@
                    <input type="submit" class="btn green" value="@Resources.Global_String_Proceed" />
                </td>
            </tr>
        </table>
    }
</div>